'''
Created on 2012-8-6

@author: daviszhao
'''
from myweb.members.models import Member
from django.core.cache import cache
from myweb import Constans

def global_info(request):
    globalinfo = {
                  'loginurl':'/member/login',
    'abouturl': '/about.html',
    'termurl': '/about/term.html',
    'privacyurl': '/about/privacy.html',
    'registerurl': '/member/register',
    'homeurl':'/member/home',
      'interesturl':'/member/interest',
      'discoverur':'/member/home',
      'logouturl':'/member/logout',
    }
    currentmember = {}
    member=interest=None
    if request.user.is_authenticated():
        member = Member.objects.get(id=request.user.id)
        key = Constans.USER_INTEREST + "#" + str(member.id)
        interest = cache.get(key)
        if interest == None:
            interest = member.interest_set.all()
            cache.set(key, interest, 9999999)
    currentmember['member'] = member
    currentmember['interest'] = interest
    return {'current':currentmember, 'globalinfo':globalinfo}

